﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Pay_My_Client.Interface.UserGestion;
using Pay_My_Client.Interface.StockGestion;
using Pay_My_Interface.Remote;
using System.Collections.ObjectModel;
using Pay_My_Interface.Entity;

namespace Pay_My_Client.Interface.Commun.SearchingList
{
    /// <summary>
    /// Logique d'interaction pour UserControl1.xaml
    /// </summary>
    public partial class ListSearchControl : UserControl
    {
        private ObservableCollection<Object> _elements;
        private ListTable _mode = ListTable.Account;

        public enum ListTable { Account, Product };

        public Collection<Object> Elements
        {
            get { return _elements; }
            set {
                _elements.Clear();
                _elements.Add(value);
            }
        }

        public ListTable Mode
        {
            get { return _mode; }
            set { _mode = value; }
        }

        public ListSearchControl()
        {
            InitializeComponent();
            _elements = new ObservableCollection<object>();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            switch (Mode)
            {
                case ListTable.Account:
                    IUser user = (new AjoutUtilisateurWindow()).ShowDialog();
                    if (user != null)
                        Remote.Functions.addUser(user);
                    break;
                case ListTable.Product:
                    break;
            }
            AjoutProduitWindow window1 = new AjoutProduitWindow();
            window1.ShowDialog();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            this.listElement.ItemsSource = _elements;
        }

        private void SearchBtm_Click(object sender, RoutedEventArgs e)
        {
            switch (Mode)
            {
                case ListTable.Account:
                    break;
                case ListTable.Product:
                    break;
            }
        }
    }
}
